package com.ruoyi.project.system.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.model.AjaxResult;
import com.ruoyi.project.system.request.SyncWeWorkDeptReqeust;
import com.ruoyi.project.system.request.SyncWeWorkEmpReqeust;
import com.ruoyi.project.system.service.ISysWeWorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统同步企业微信组织架构
 *
 * @author thanks
 */
@RestController
@RequestMapping("/system/wework")
public class SystemWeWorkController extends BaseController {
    @Autowired
    private ISysWeWorkService weWorkService;

    /**
     * 同步企业微信部门列表
     */
    @PostMapping("/sync-wework-dept")
    public AjaxResult syncWeWorkDept(@Validated @RequestBody SyncWeWorkDeptReqeust reqeust) {
        Long tenantId = getTenantId();

        weWorkService.syncWeWorkDept(tenantId);
        // TODO
        return AjaxResult.success();
    }


    /**
     * 同步企业微信人员列表
     */
    @PostMapping("/sync-wework-emp")
    public AjaxResult syncWeWorkEmp(@Validated @RequestBody SyncWeWorkEmpReqeust reqeust) {
        // TODO
        Long tenantId = getTenantId();
        Long taskId = weWorkService.syncWeWorkEmp(tenantId, reqeust);
        return AjaxResult.success();
    }
}
